package login

import (
	"context"
	v1 "donkey-admin/api/role/v1"
	"donkey-admin/internal/dao"
	"donkey-admin/internal/model/do"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/google/uuid"
)

func (s *sRole) RoleAdd(ctx context.Context, req *v1.RoleAddReq) (res *v1.RoleAddRes, err error) {
	_, err = dao.SysRole.Ctx(ctx).Insert(&do.SysRole{
		Uuid:       uuid.New().String(),
		RoleName:   req.RoleName,
		RoleCode:   req.RoleCode,
		RoleDesc:   req.RoleDesc,
		RoleStatus: req.RoleStatus,
	})
	if err != nil {
		g.Log().Error(ctx, err)
		return nil, err
	}

	return &v1.RoleAddRes{}, nil
}
